#ifndef SETUPDIALOG_H
#define SETUPDIALOG_H

#include <QDialog>
class RuleItemModel;
class RuleItemDelegate;
class QPrinter;
#include "global.h"

namespace Ui {
class SetupDialog;
}

class SetupDialog : public QDialog
{
    Q_OBJECT

public:
    explicit SetupDialog(QWidget *parent = 0);
    ~SetupDialog();

    void getConfigData(QList<PrintRule*> &rules, GeneralSettings &gsettings,
                           PrintFormat &pformat, FilmPaperMap &fpmap);
    static void getConfigDataFromFile(QList<PrintRule*> &rules, GeneralSettings &gsettings,
                                      PrintFormat &pformat, FilmPaperMap &fpmap);

protected slots:
    void onInsertRule();
    void onRemoveRule();
    void onApply();
    void onOk();

    void onHeaderIcon();
    void onHeaderFont();
    void onHeaderColor();
    void onFooterIcon();
    void onFooterFont();
    void onFooterColor();
    void onPrintTest();
    void onSelectDir();
    void setAutoRun(bool yes);

private:
    static void getSettingsFromFile(GeneralSettings &gsettings, PrintFormat &pformat,
                                    FilmPaperMap &fpmap);
    void initUi();
    void readConfig();
    void saveConfig();

    void testAll(QPrinter *printer);
    void testResolution(QPrinter *printer);
    void testGrayscale(QPrinter *printer);
    void testDistortion(QPrinter *printer);

    Ui::SetupDialog *ui;

    RuleItemModel *model;
    RuleItemDelegate *delegate;

    GeneralSettings general;
    PrintFormat format;
    FilmPaperMap paperMap;
};

#endif // SETUPDIALOG_H
